<%--
  Created by IntelliJ IDEA.
  User: 练钰华
  Date: 2025/11/5
  Time: 13:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
  <title>编辑员工 - 员工信息管理系统</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
</head>
<body>
<%-- 顶部导航栏 --%>
<div class="navbar">
  <div class="container">
    <h1>员工信息管理系统</h1>
    <div class="user-info">
      <span>欢迎您，${loginUser.username}！</span>
      <a href="${pageContext.request.contextPath}/LogoutServlet" class="btn logout-btn">退出登录</a>
    </div>
  </div>
</div>

<%-- 编辑员工表单（回显原有数据） --%>
<div class="container">
  <div class="form-container">
    <h2>编辑员工信息</h2>
    <form action="${pageContext.request.contextPath}/EmployeeServlet?action=update" method="post">
      <%-- 隐藏员工ID（用于更新时定位数据） --%>
      <input type="hidden" name="id" value="${employee.id}">

      <div class="form-row">
        <div class="form-group">
          <label for="name">姓名</label>
          <input type="text" id="name" name="name" required value="${employee.name}">
        </div>
        <div class="form-group">
          <label for="department">部门</label>
          <input type="text" id="department" name="department" required value="${employee.department}">
        </div>
      </div>
      <div class="form-row">
        <div class="form-group">
          <label for="position">职位</label>
          <input type="text" id="position" name="position" required value="${employee.position}">
        </div>
        <div class="form-group">
          <label for="salary">薪资</label>
          <input type="number" step="0.01" id="salary" name="salary" required value="${employee.salary}">
        </div>
      </div>
      <div class="form-row">
        <div class="form-group">
          <label for="email">邮箱</label>
          <input type="email" id="email" name="email" value="${employee.email}">
        </div>
        <div class="form-group">
          <label for="phone">电话</label>
          <input type="text" id="phone" name="phone" value="${employee.phone}">
        </div>
      </div>
      <div class="form-group">
        <label for="hire_date">入职日期</label>
        <input type="date" id="hire_date" name="hire_date" required value="${employee.hire_date}">
      </div>
      <div style="margin-top: 30px; display: flex; gap: 10px;">
        <button type="submit" class="btn edit-btn">保存修改</button>
        <a href="${pageContext.request.contextPath}/EmployeeServlet?action=list" class="btn">取消</a>
      </div>
    </form>
  </div>
</div>
</body>
</html>
